<template>
  <div class="plot-view">
    <div class="left">
      <CommonPlot class="card">
        <template #title>
          <div>武汉各区出行人口统计</div>
        </template>
        <ColumnChart :data="districtPeople" v-bind="config" class="chart" />
      </CommonPlot>
      <CommonPlot class="card">
        <template #title>
          <div>武汉各区公交线路统计</div>
        </template>
        <RoseChart :data="busData" v-bind="busConfig" class="chart" />
      </CommonPlot>
    </div>
    <div class="right">
      <CommonPlot class="card">
        <template #title>
          <div>武汉三镇人口统计</div>
        </template>
        <PieChart :data="peopleData" v-bind="peopleConfig" class="chart" />
      </CommonPlot>
      <CommonPlot class="card">
        <template #title>
          <div>武汉三甲医院</div>
        </template>
        <div class="box">
          <div class="item" v-for="item in hospital">
            <h5>{{ item.title }}</h5>
            <div class="img">
              <img :src="item.src" :height="item.size" :width="item.size" />
            </div>
          </div>
        </div>
      </CommonPlot>
      <CommonPlot class="card">
        <template #title>
          <div>武汉市高校学生统计</div>
        </template>
        <div class="box">
          <div class="item" v-for="item in school">
            <h5>{{ item.title }}</h5>
            <div class="img">
              <img :src="item.src" :height="item.size" :width="item.size" />
            </div>
          </div>
        </div>
      </CommonPlot>
    </div>
  </div>
</template>

<script setup>
import { districtPeople, config } from '../mock/districtPeople.js';
import { busData, config as busConfig } from '../mock/bus.js';
import { peopleData, config as peopleConfig } from '../mock/people.js';
import { ColumnChart, RoseChart, PieChart } from '@opd/g2plot-vue';

import CommonPlot from '../components/CommonPlot.vue';
// console.log(districtPeople);

const hospital = [
  {
    title: '医院30家',
    src: '/icons/医院.png',
    size: 65,
  },
  {
    title: '门诊部300个',
    src: '/icons/门诊.png',
    size: 40,
  },
  {
    title: '病床3000张',
    src: '/icons/病床.png',
    size: 50,
  },
];

const school = [
  {
    title: '高校130家',
    src: '/icons/学校.png',
    size: 40,
  },
  {
    title: '在校大学生100万',
    src: '/icons/学生.png',
    size: 40,
  },
];
</script>

<style lang="scss" scoped>
.plot-view {
  .left {
    position: fixed;
    top: 80px;
    left: 80px;
  }
  .right {
    position: absolute;
    top: 80px;
    right: 80px;
  }
  .card {
    margin-bottom: 20px;
    position: relative;
  }
  .chart {
    width: 300px;
    height: 200px;
    position: relative;
  }
  .box {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  .item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-bottom: 20px;
  }

  .item .img {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
